package com.sunwayworld.basemodule.basedata.remarknote.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.basedata.remarknote.dao.LimsRemarkNoteDao;
import com.sunwayworld.basemodule.basedata.remarknote.bean.LimsRemarkNoteBean;
import com.sunwayworld.basemodule.basedata.remarknote.service.LimsRemarkNoteService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsRemarkNoteServiceImpl implements LimsRemarkNoteService {

    @Autowired
    private LimsRemarkNoteDao limsRemarkNoteDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsRemarkNoteDao getDao() {
        return limsRemarkNoteDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsRemarkNoteBean limsRemarkNote = jsonWrapper.parseUnique(LimsRemarkNoteBean.class);
        limsRemarkNote.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsRemarkNote);
        return limsRemarkNote.getId();
    }

}
